package com.tc.vms.producer;

import com.tc.vms.iface.VmsQos;


public class PubQoS extends VmsQos {
    private boolean durable;
    private boolean mandatory;

    public PubQoS() {
        durable = true;
        mandatory = true;
    }

    public boolean durable() {
        return this.durable;
    }


    /**
     * This flag tells the server how to react if a message cannot be routed to
     * a queue. Specifically, if mandatory is set and after running the bindings
     * the message was placed on zero queues then the message is returned to the
     * sender (with a basic.return). If mandatory had not been set under the
     * same circumstances the server would silently drop the message
     *
     * @return
     */
    public boolean mandatory() {
        return this.mandatory;
    }

    /**
     * It flags whether message is durable.which's always durable in kafka.
     *
     * @param durable true is durable ,false is non-durable
     * @return
     */
    public PubQoS durable(boolean durable) {
        this.durable = durable;
        return this;
    }

    /**
     * This flag tells the server how to react if a message cannot be routed to
     * a queue. Specifically, if mandatory is set and after running the bindings
     * the message was placed on zero queues then the message is returned to the
     * sender (with a basic.return). If mandatory had not been set under the
     * same circumstances the server would silently drop the message. Put this
     * message on at least one queue. If you can't, send it back to me.
     *
     * @param mandatory false default
     * @return
     */
    public PubQoS mandatory(boolean mandatory) {
        this.mandatory = mandatory;
        return this;
    }
}
